package com.xy.wsl.api.controller.ThirdApp;

import com.xy.wsl.api.authorize.Authorize;
import com.xy.wsl.api.response.ResponseResult;
import com.xy.wsl.api.sql.entity.ThirdApp.ThirdApp;
import com.xy.wsl.api.sql.services.ThirdApp.ThirdAppService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/thirdApp")
@Slf4j
@RestController
@ResponseResult
public class ThirdAppController {

    @Autowired
    ThirdAppService service;

    @PutMapping
//    @Authorize
    public String put(@RequestBody ThirdApp request) {
        int result = service.insert(request);
        if (result == 1) {
            return  "保存成功";
        }
        throw new RuntimeException("保存失败");
    }

    @GetMapping("{appid}")
    public Object getApp(@PathVariable String appid) {
        return com.xy.wsl.api.utils.ThirdApp.getAppAndToken(appid,service);
    }
}
